<!-- 提示弹窗 -->
<template>
	<view class='cu-modal' :class='{show: show}'>
		<view class='modal'>
			<view class="">
				<view class='alert-title' v-if='params.showTitle'>{{params.title}}</view>
				<view class='alert-content'>{{params.content}}</view>
				<slot name="box"></slot>
			</view>
			<view class='alert-foot'>
				<view class='alert-btn default' @click='handleClose' v-if="params.leftBtn">{{params.leftBtn}}</view>
				<view class='alert-btn yellow' @click='handleConfirm'>{{params.rightBtn}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: false, 
				params: {},
			}
		},
		methods: {
			open(params) {
				this.params.showTitle = params.showTitle || true;
				this.params.title = params.title || '提示'; //标题
				this.params.content = params.content || ''; //内容
				this.params.leftBtn = params.leftBtn == '' ? '' :  params.leftBtn || '取消'; //取消按钮
				this.params.rightBtn = params.rightBtn || '确定'; //确认按钮
				this.params.success = params.success || null; //确认方法回调
				this.params.close = params.close || null; //取消方法回调
				this.show = true;
			},
			close() {
				this.show = false;
			},
			handleClose() {
				if(this.params.close) {
					this.params.close()
				}
				this.close()
			},
			handleConfirm() {
				if(this.params.success) {
					this.params.success()
				}
				this.close()
			}
		}
	}
</script>

<style scoped lang="scss">
	.modal {
		position: absolute;
		top: 50%;
		left: 50%;
		transform: translate(-50%,-50%);
		background: #FFFFFF;
		text-align: left;
		padding: 40rpx;
		
		min-height: 441rpx;
		width: 600rpx;
		border-radius: 32rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		
		.alert-title {
			font-size: 36rpx;
			font-weight: 600;
			color: #3D3D3D;
			text-align: center;
		}
		
		.alert-content {
			font-size: 32rpx;
			min-height: 140rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			color: var(--h1Color);
			margin-top: 20rpx;
			font-weight: 500;
			text-align: center;
			// padding: 0 124rpx;
		}
		
		.alert-foot {
			padding: 50rpx 0 0 0;
			display: flex;
			align-items: center;
			justify-content: center;
			
			.alert-btn {
				// width: 250rpx;
				width: 100%;
				height: 95rpx;
				border-radius: 48rpx;
				font-size: 32rpx;
				font-weight: 500;
				display: flex;
				align-items: center;
				justify-content: center;
				
				&.default {
					background: #F8F8F8;
					margin-right: 40rpx;
				}
				
				&.yellow {
					background: var(--primaryBg);
					color: var(--h1Color);
					font-family: PingFangSC, PingFang SC;
					font-weight: 500;
				}
			}
		}
		
	}
</style>